﻿using UnityEngine;
using System.IO;
using System.Collections;

namespace AutoRoot
{
   public class Downloader
   {
      public static void download(string src, string fileName)
      {
         WWW www = new WWW(src);

         while (!www.isDone)
         {
            MonoBehaviour.print("downloaded " + (www.progress * 100).ToString("F0") + "%");
         }
         MonoBehaviour.print("downloaded finished");
         File.WriteAllBytes(Application.persistentDataPath + "/" + fileName, www.bytes);
         MonoBehaviour.print("wrote to " + Application.persistentDataPath + "/" + fileName);
      }
   }
}
